import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path';

// https://vite.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src'), // 设置 @ 符号指向 src 目录
      '@assets': path.resolve(__dirname, 'src/assets'), // 设置 @assets 符号指向 src/assets 目录
      '@components': path.resolve(__dirname, 'src/components'), // 设置 @components 符号指向 src/components 目录
      '@api': path.resolve(__dirname, 'src/api'), // 设置 @api 符号指向 src/api 目录
      '@utils': path.resolve(__dirname, 'src/utils'), // 设置 @utils 符号指向 src/utils 目录
      '@views': path.resolve(__dirname, 'src/views'), // 设置 @views 符号指向 src/views 目录
    },
  },
  base: '/', 
  build: {
    outDir: 'dist', 
    emptyOutDir: true,
    rollupOptions: {
      output: {
        // 将静态资源放到 dist/static 目录下
        assetFileNames: 'static/[name]-[hash][extname]', 
        chunkFileNames: 'static/[name]-[hash].js',
        entryFileNames: 'static/[name]-[hash].js',
      },
    },
  },
})